package com.byx.chatclient.im;

import android.util.SparseArray;

import com.byx.imclientutil.entity.MessageType;

/**
 * MessageHandlerFactory
 *
 * @author Superb
 * @date 2021/4/5 13:11
 */
public class MessageHandlerFactory {
    private static final SparseArray<IMessageHandler> HANDLERS = new SparseArray<>();

    static {
        /*
         *  单聊消息处理handler
         */
        HANDLERS.put(MessageType.SINGLE_CHAT_MSG, new SingleChatMessageHandler());
        /*
         * 群聊消息处理handler
         */
        HANDLERS.put(MessageType.GROUP_CHAT_MSG, new GroupChatMessageHandler());
        /*
         *服务端返回的消息发送状态报告处理handler
         */
        HANDLERS.put(MessageType.SERVER_STATUS_REPORT, new ServerReportMessageHandler());
    }

    /**
     * 根据消息类型获取对应的处理handler
     *
     * @param msgType
     * @return
     */
    public static IMessageHandler getHandlerByMsgType(int msgType) {
        return HANDLERS.get(msgType);
    }
}
